/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author A7med Kotb
 */
@Entity
@Table(name = "extraprice")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Extraprice.findAll", query = "SELECT e FROM Extraprice e"),
    @NamedQuery(name = "Extraprice.findById", query = "SELECT e FROM Extraprice e WHERE e.id = :id"),
    @NamedQuery(name = "Extraprice.findBySize", query = "SELECT e FROM Extraprice e WHERE e.size = :size"),
    @NamedQuery(name = "Extraprice.findByPrice", query = "SELECT e FROM Extraprice e WHERE e.price = :price")})
public class Extraprice implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "size")
    private int size;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "price")
    private BigDecimal price;
    @JoinColumn(name = "categoryId", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Category categoryId;
    @JoinColumn(name = "extraId", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Extra extraId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "extraPriceId")
    private Collection<Orderdetail> orderdetailCollection;

    public Extraprice() {
    }

    public Extraprice(Integer id) {
        this.id = id;
    }

    public Extraprice(Integer id, int size, BigDecimal price) {
        this.id = id;
        this.size = size;
        this.price = price;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Category getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Category categoryId) {
        this.categoryId = categoryId;
    }

    public Extra getExtraId() {
        return extraId;
    }

    public void setExtraId(Extra extraId) {
        this.extraId = extraId;
    }

    @XmlTransient
    public Collection<Orderdetail> getOrderdetailCollection() {
        return orderdetailCollection;
    }

    public void setOrderdetailCollection(Collection<Orderdetail> orderdetailCollection) {
        this.orderdetailCollection = orderdetailCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Extraprice)) {
            return false;
        }
        Extraprice other = (Extraprice) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pojo.Extraprice[ id=" + id + " ]";
    }
    
}
